package com.atguigu.day22.exer.codetest;

import java.util.Arrays;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/28 10:55
 * @注释 请写一个冒泡排序，实现{5,7,3,9,2}从小到大排序
 */
public class CodeTest04 {
    public static void main(String[] args) {
        int[] arr = {5,7,3,9,2};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
